<?php

class User
{
    public static $username;
    protected $age;
    private $sex;

//    public function __construct($args)
//    {
//        $this->username = $args['username'];
//        $this->age = $args['age'];
//        $this->sex = $args['sex'];
//    }

    public function getUsername()
    {
        return $this->username;
        return $obj::$username;
    }
}

# 为User类创建ReflectionClass类  参数可为包含类名的字符串 或者 类的对象
$reflect = new ReflectionClass("User");
# 返回初始化完成后的 ReflectionClass 实例。
//$user = $reflect->newInstance(['username' => 'jesse', 'age' => 21, 'sex' => 'man']);
//调用实例方法
//echo $user->getUsername().PHP_EOL;
$reflection_property = $reflect->getProperty('username');
$reflection_property->setAccessible(true);
$reflection_property->setValue($reflect,'wyqgg');
$obj = new User();
var_dump($obj::$username);
